package services;

import Dao.UserDao;
import entity.UserBean;

import java.util.List;

public class UserServiceAll {
    private UserDao userDao = new UserDao();

    public int changeState(int uid,boolean ustate){ return userDao.changeState(uid,ustate); }

    public List<UserBean> all(){ return userDao.all(); }

    public UserBean one(int id){ return userDao.one(id); }

    public List<UserBean> SearchByname(String searchName){ return userDao.searchbyname(searchName); };
    //根据id获取个人信息
    public UserBean personalInformation(int id) {
        return userDao.personalInformation(id);
    }
    //修改个人信息
    public int updatePersonalInformation(UserBean userBean) {
        return userDao.updatePersonalInformation(userBean);
    }

    public int add(UserBean user){
        if(user == null){
            throw new RuntimeException("用户对象为空");
        }
        return userDao.add(user);
    }

    public int updateUsersRoleId(int uid,int radioRolesCheckedId){ return userDao.updateUsersRoleId(uid,radioRolesCheckedId); }

    public int update(UserBean user){
        if(user == null){
            throw new RuntimeException("用户对象为空");
        }
        return userDao.update(user);
    }

    public int dele(int id){return userDao.del(id);}

    public static void main(String[] args) {
        List<UserBean> all = new UserServiceAll().all();
        for (UserBean userBean :all) {
            System.out.println(userBean);
        }

    }
}
